<template>
    <div>
        <van-nav-bar
            title="修改地址"
            left-text="返回"
            left-arrow
            @click-left="onClickLeft"
        />      
        <van-address-edit
            :area-list="areaList"
            :show-delete=false
            :area-columns-placeholder="['请选择', '请选择', '请选择']"
            @save="onSave"
        />        
    </div>
</template>
<script>
export default {
    data() {
        return {
            areaList:'',
            id:''
        }
    },
    created() {
        this.areaList={
            province_list: {
                10000: '北京市',
                20000: '天津市'
            },
            city_list: {
                110100: '北京市',
                110200: '县',
                120100: '天津市',
                120200: '县'
            },
            county_list: {
                110101: '东城区',
                110102: '西城区',
                110105: '朝阳区',
                110106: '丰台区',
                120101: '和平区',
                120102: '河东区',
                120103: '河西区',
                120104: '南开区',
                120105: '河北区',
            }
        }  
        this.id=sessionStorage.getItem('changeid')
        console.log(this.$store.getters['common/getAddress'])
    },
    methods: {
        onClickLeft(){
            this.$router.go(-1)
        },
        //修改后保存
        onSave(content){
            console.log(this.id)
            let arr=this.$store.getters['common/getAddress']
            content.address=content.province+content.city+content.county+content.addressDetail
            content.id=content.areaCode+Math.ceil(Math.random()*99+1)
            arr[this.id]=content
            this.$store.commit('common/setAddress',arr)
            this.$toast.success('修改成功')
        }
    },
}
</script>